package com.dongpu.springboot.rabbitmq.utils;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author biyuyang
 */
public class ConnectionUtil {

	public static Connection getConnection() throws IOException, TimeoutException {

		//1.创建连接到rabbitMQ的连接工厂
		ConnectionFactory factory = new ConnectionFactory();

		//2.设置连接所需信息
		factory.setHost("10.19.206.92");
		factory.setPort(5672);
		factory.setUsername("admin1");
		factory.setPassword("2015");
		factory.setVirtualHost("/");

		//3.创建连接
		Connection connection = factory.newConnection();

		return connection;
	}

}
